package 设计模式.模板模式;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;

/**
 * 日志模板的默认实现
 *
 * @author Administrator
 */
public class DefualtLogTemplate {
    private Logger logger = Logger.getLogger(this.getClass().getSimpleName());

    public Object execute(LogCallBack callBack) {
        Object resutl = null;
        try {
            Method method = LogCallBack.class.getMethod("call");
            resutl = method.invoke(callBack, null);
            logger.info(resutl.toString());//记录日志
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resutl;
    }
}
